import { mapGetters } from 'vuex'

export default {
	computed: {
		...mapGetters('m_cart', ['total'])
	},
	onShow() {
		if(this.total !==0)this.setBadge()
	},
	watch:{
		total(newVal){
			if(newVal===0) {
				uni.removeTabBarBadge({index:2})
			}else{
				this.setBadge()
			}
		}
	},
	methods: {
		setBadge() {
			uni.setTabBarBadge({
				index: 2,
				text: this.total + ''
			})
		}
	}

}
